eliminate redundant route_head data member rte_waypt_ct, replacing it with a member function rte_waypt_ct() that gets the count from the waypoint_list container.
}
/* remove empty route */
- if (route->rte_waypt_ct == 0) {
+ if (route->rte_waypt_ct() == 0) {
route_del_head(route);
} else {
bcr_create_waypts_from_route(route);
QString rte_desc;
UrlList rte_urls;
int rte_num;
- int rte_waypt_ct; /* # waypoints in waypoint list */
FormatSpecificDataList fs;
gb_color line_color; /* Optional line color for rendering */
int line_width; /* in pixels (sigh). < 0 is unknown. */
route_head(const route_head& other) = delete;
route_head& operator=(const route_head& rhs) = delete;
~route_head();
+
+ int rte_waypt_ct() const {return waypoint_list.count();} /* # waypoints in waypoint list */
};
using route_hdr = void (*)(const route_head*);
cur_info = &route_info[route_idx];
cur_info->prev_wpt = nullptr;
cur_info->total = 0;
- if (rte->rte_waypt_ct <= 0) {
+ if (rte->rte_waypt_ct() <= 0) {
return;
}
cur_info = &route_info[route_idx];
cur_info->prev_wpt = nullptr;
cur_info->total = 0;
- if (track->rte_waypt_ct <= 0) {
+ if (track->rte_waypt_ct() <= 0) {
return;
}
/*******************************************************************************/
-#define ELEMENTS(a) a->rte_waypt_ct
+#define ELEMENTS(a) a->rte_waypt_ct()
#define NOT_EMPTY(a) (a && *a)
static void
static void
track_disp_cb(const route_head* trk)
{
- int waypt_ct = trk->rte_waypt_ct;
+ int waypt_ct = trk->rte_waypt_ct();
if (waypt_ct <= 0) {
return;
static void
route_disp_cb(const route_head* rte)
{
- int waypt_ct = rte->rte_waypt_ct;
+ int waypt_ct = rte->rte_waypt_ct();
if (waypt_ct <= 0) {
return;
static void count_track_styles(const route_head* rte)
{
- if (rte->rte_waypt_ct > 0) {
+ if (rte->rte_waypt_ct() > 0) {
ts_count++;
}
}
static void write_trk_style(const route_head* trk)
{
- if (trk->rte_waypt_ct > 0) {
+ if (trk->rte_waypt_ct() > 0) {
fwrite_string(file_out, trk->rte_name);
fwrite_byte(file_out, 1);
fwrite_long(file_out, 0);
trk_head = nullptr;
last_time = 0;
- if (trk->rte_waypt_ct > 0) {
+ if (trk->rte_waypt_ct() > 0) {
trk_head = (humminbird_trk_header_t*) xcalloc(1, sizeof(humminbird_trk_header_t));
trk_points = (humminbird_trk_point_t*) xcalloc(max_points, sizeof(humminbird_trk_point_t));
humminbird_rte_head(const route_head* rte)
{
humrte = nullptr;
- if (rte->rte_waypt_ct > 0) {
+ if (rte->rte_waypt_ct() > 0) {
humrte = (humminbird_rte_t*) xcalloc(1, sizeof(*humrte));
}
}
max_waypt_ct = 0;
}
// Find other track with the most waypoints
- if (rh->rte_waypt_ct > max_waypt_ct &&
+ if (rh->rte_waypt_ct() > max_waypt_ct &&
(rh->rte_name.isEmpty() ||
(!rh->rte_name.startsWith(PRESTRKNAME) &&
!rh->rte_name.startsWith(GNSSTRKNAME)))) {
head = rh;
- max_waypt_ct = rh->rte_waypt_ct;
+ max_waypt_ct = rh->rte_waypt_ct();
}
}
unsigned char have_takeoff = 0;
char flight_date[7] = "000000";
char task_desc[MAXRECLEN] = "";
- int num_tps = rte->rte_waypt_ct - 2;
+ int num_tps = rte->rte_waypt_ct() - 2;
struct tm* tm;
time_t rte_time;
static unsigned int task_num = 1;
}
gbfprintf(fout, "\t<INFORMATIONS>\n");
- gbfprintf(fout, "\t\t<NB_ETAPES>%d</NB_ETAPES>\n", track_hdr->rte_waypt_ct);
+ gbfprintf(fout, "\t\t<NB_ETAPES>%d</NB_ETAPES>\n", track_hdr->rte_waypt_ct());
if (!track_hdr->rte_desc.isEmpty()) {
gbfprintf(fout, "\t\t<DESCRIPTION>%s</DESCRIPTION>\n", STRFROMUNICODE(track_hdr->rte_desc));
}
if (wpt_timespan_begin.isValid() && wpt_timespan_end.isValid()) {
// If there are some Waypoints, then distribute the TimeSpan to all Waypoints
- if (trk_head->rte_waypt_ct > 0) {
+ if (trk_head->rte_waypt_ct() > 0) {
qint64 timespan_ms = wpt_timespan_begin.msecsTo(wpt_timespan_end);
- if (trk_head->rte_waypt_ct < 2) {
+ if (trk_head->rte_waypt_ct() < 2) {
fatal(MYNAME ": attempt to interpolate TimeSpan with too few points.");
}
- qint64 ms_per_waypoint = timespan_ms / (trk_head->rte_waypt_ct - 1);
+ qint64 ms_per_waypoint = timespan_ms / (trk_head->rte_waypt_ct() - 1);
foreach (Waypoint* trackpoint, trk_head->waypoint_list) {
trackpoint->SetCreationTime(wpt_timespan_begin);
wpt_timespan_begin = wpt_timespan_begin.addMSecs(ms_per_waypoint);
}
}
- if (!gx_trk_head->rte_waypt_ct) {
+ if (!gx_trk_head->rte_waypt_ct()) {
track_del_head(gx_trk_head);
}
delete gx_trk_times;
writer->writeOptionalTextElement(QStringLiteral("name"), header->rte_name);
kml_output_trkdescription(header, td);
- if (export_points && header->rte_waypt_ct > 0) {
+ if (export_points && header->rte_waypt_ct() > 0) {
// Put the points in a subfolder
writer->writeStartElement(QStringLiteral("Folder"));
writer->writeTextElement(QStringLiteral("name"), QStringLiteral("Points"));
void KmlFormat::kml_output_tailer(const route_head* header)
{
- if (export_points && header->rte_waypt_ct > 0) {
+ if (export_points && header->rte_waypt_ct() > 0) {
writer->writeEndElement(); // Close Folder tag
}
// Add a linestring for this track?
- if (export_lines && header->rte_waypt_ct > 0) {
+ if (export_lines && header->rte_waypt_ct() > 0) {
int needs_multigeometry = 0;
foreach (const Waypoint* tpt, header->waypoint_list) {
void KmlFormat::kml_track_hdr(const route_head* header) const
{
computed_trkdata td = track_recompute(header);
- if (header->rte_waypt_ct > 0 && (export_lines || export_points)) {
+ if (header->rte_waypt_ct() > 0 && (export_lines || export_points)) {
kml_output_header(header, &td);
}
}
void KmlFormat::kml_track_tlr(const route_head* header)
{
- if (header->rte_waypt_ct > 0 && (export_lines || export_points)) {
+ if (header->rte_waypt_ct() > 0 && (export_lines || export_points)) {
kml_output_tailer(header);
}
}
* head here.
*/
while (max_position_points &&
- (posn_trk_head->rte_waypt_ct >= max_position_points)) {
+ (posn_trk_head->rte_waypt_ct() >= max_position_points)) {
Waypoint* tonuke = posn_trk_head->waypoint_list.front();
track_del_wpt(posn_trk_head, tonuke);
}
gbfputint32(text_len, file_out);
gbfwrite(CSTR(name), 1, text_len, file_out);
- auto num_trail_points = (short) trk->rte_waypt_ct;
+ auto num_trail_points = (short) trk->rte_waypt_ct();
short max_trail_size = MAX_TRAIL_POINTS;
if (num_trail_points > max_trail_size) {
num_trail_points = max_trail_size;
gbfputs(name, file_out);
/* num legs */
- auto num_legs = (short) rte->rte_waypt_ct;
+ auto num_legs = (short) rte->rte_waypt_ct();
gbfputint16(num_legs, file_out);
char route_reversed=0;
gbfwrite(&route_reversed, 1, 1, file_out);
{
if (global_opts.debug_level >= 1) {
printf(MYNAME " writing route #%d (%s) with %d waypts\n",
- route_uid, qPrintable(rte->rte_name), rte->rte_waypt_ct);
+ route_uid, qPrintable(rte->rte_name), rte->rte_waypt_ct());
}
const auto* fs = reinterpret_cast<lowranceusr4_fsdata*>(rte->fs.FsChainFind(kFsLowranceusr4));
lowranceusr4_writestr(rte->rte_name, file_out, 2);
/* Num Legs */
- gbfputint32(rte->rte_waypt_ct, file_out);
+ gbfputint32(rte->rte_waypt_ct(), file_out);
}
void
}
}
- trail_point_count += (short) trk->rte_waypt_ct;
+ trail_point_count += (short) trk->rte_waypt_ct();
}
void
{
if (global_opts.debug_level >= 1) {
printf(MYNAME " writing trail %d (%s) with %d trailpoints\n",
- trail_uid, qPrintable(trail->rte_name), trail->rte_waypt_ct);
+ trail_uid, qPrintable(trail->rte_name), trail->rte_waypt_ct());
}
/* UID unit number */
// }
/* Trackpoint count */
- gbfputint32(trail->rte_waypt_ct, file_out);
+ gbfputint32(trail->rte_waypt_ct(), file_out);
}
void
QString icon_token;
/* count waypoints for this route */
- int i = rte->rte_waypt_ct;
+ int i = rte->rte_waypt_ct();
/* number of output PMGNRTE messages at 2 points per line */
int numlines = (i / 2) + (i % 2);
gbfputint32(rte->rte_num, mapsend_file_out);
/* # of waypoints to follow... */
- gbfputint32(rte->rte_waypt_ct, mapsend_file_out);
+ gbfputint32(rte->rte_waypt_ct(), mapsend_file_out);
}
static void
DBG((sobj, "for \"%s\" \n", data->name));
}
- if (rte->rte_waypt_ct == 0) { /* don't keep empty routes */
+ if (rte->rte_waypt_ct() == 0) { /* don't keep empty routes */
route_del_head(rte);
data->data = nullptr;
}
}
}
- if (trk->rte_waypt_ct == 0) {
+ if (trk->rte_waypt_ct() == 0) {
track_del_head(trk);
data->data = nullptr;
}
static void
mmo_enum_route_cb(const route_head* rte)
{
- if (rte->rte_waypt_ct > 0) {
+ if (rte->rte_waypt_ct() > 0) {
mmo_obj_ct++;
}
}
{
time_t time = 0x7FFFFFFF;
- if (rte->rte_waypt_ct <= 0) {
+ if (rte->rte_waypt_ct() <= 0) {
return;
}
mmo_register_object(objid, rte, rtedata);
mmo_write_category("CCategory", "Route");
gbfputc(0, fout); /* unknown */
- gbfputuint16(rte->rte_waypt_ct, fout);
+ gbfputuint16(rte->rte_waypt_ct(), fout);
}
static void
mmo_write_rte_tail_cb(const route_head* rte)
{
- if (rte->rte_waypt_ct <= 0) {
+ if (rte->rte_waypt_ct() <= 0) {
return;
}
- DBG(("write", "route with %d point(s).\n", rte->rte_waypt_ct));
+ DBG(("write", "route with %d point(s).\n", rte->rte_waypt_ct()));
if (mmo_version >= 0x12) {
if (rte->line_color.bbggrr < 0) {
static void
mmo_write_trk_head_cb(const route_head* trk)
{
- if (trk->rte_waypt_ct <= 0) {
+ if (trk->rte_waypt_ct() <= 0) {
return;
}
int objid = mmo_write_obj_head("CObjTrack",
trk->rte_name.isEmpty() ? "Track" : CSTR(trk->rte_name), gpsbabel_time, obj_type_trk);
mmo_write_category("CCategory", "Track");
- gbfputuint16(trk->rte_waypt_ct, fout);
+ gbfputuint16(trk->rte_waypt_ct(), fout);
mmo_register_object(objid, trk, trkdata);
}
static void
mmo_write_trk_tail_cb(const route_head* trk)
{
- if (trk->rte_waypt_ct <= 0) {
+ if (trk->rte_waypt_ct() <= 0) {
return;
}
static void
serial_write_route_start(const route_head* route)
{
- route_ids = (unsigned int*) xmalloc(route->rte_waypt_ct * sizeof(unsigned));
+ route_ids = (unsigned int*) xmalloc(route->rte_waypt_ct() * sizeof(unsigned));
route_id_ptr = 0;
}
void
OsmFormat::osm_rte_disp_head(const route_head* route)
{
- skip_rte = route->rte_waypt_ct <= 0;
+ skip_rte = route->rte_waypt_ct() <= 0;
if (skip_rte) {
return;
break;
case 2:
/* new track flag */
- if ((str.toInt() == 1) && (trk_head->rte_waypt_ct > 0)) {
+ if ((str.toInt() == 1) && (trk_head->rte_waypt_ct() > 0)) {
trk_head = new route_head;
track_add_head(trk_head);
if (trk_name) {
void PositionFilter::position_process_any_route(const route_head* rh, int type)
{
- if (rh->rte_waypt_ct != 0) {
+ if (rh->rte_waypt_ct() != 0) {
cur_rte = const_cast<route_head*>(rh);
position_runqueue(&cur_rte->waypoint_list, type);
cur_rte = nullptr;
static void
enum_route_hdr_cb(const route_head* rte)
{
- is_fatal(rte->rte_waypt_ct > 50,
+ is_fatal(rte->rte_waypt_ct() > 50,
MYNAME ": Routes with more than 50 points are not supported by Raymarine!");
}
route_head::route_head() :
rte_num(0),
- rte_waypt_ct(0),
// line_color(),
line_width(-1),
session(curr_session())
void
RouteList::del_head(route_head* rte)
{
- waypt_ct -= rte->rte_waypt_ct;
+ waypt_ct -= rte->rte_waypt_ct();
const int idx = this->indexOf(rte);
assert(idx >= 0);
removeAt(idx);
void
RouteList::add_wpt(route_head* rte, Waypoint* wpt, bool synth, const QString& namepart, int number_digits)
{
- rte->rte_waypt_ct++; /* waypoints in this route */
++waypt_ct;
rte->waypoint_list.add_rte_waypt(waypt_ct, wpt, synth, namepart, number_digits);
if ((this == global_route_list) || (this == global_track_list)) {
RouteList::del_wpt(route_head* rte, Waypoint* wpt)
{
rte->waypoint_list.del_rte_waypt(wpt);
- rte->rte_waypt_ct--;
--waypt_ct;
}
rte_new->rte_desc = rte_old->rte_desc;
rte_new->rte_urls = rte_old->rte_urls;
rte_new->rte_num = rte_old->rte_num;
- // rte_waypt_ct created below with add_wpt.
rte_new->fs = rte_old->fs.FsChainCopy();
rte_new->line_color = rte_old->line_color;
rte_new->line_width = rte_old->line_width;
record = ReadRecord(infile, recsize);
stringlen = le_read16((uint16_t*)record);
if (split && stringlen) {
- if (track_head->rte_waypt_ct) {
+ if (track_head->rte_waypt_ct()) {
old_track_head = track_head;
track_head = new route_head;
if (timesynth) {
void
ShapeFormat::poly_init(const route_head* rte)
{
- const int ct = rte->rte_waypt_ct;
+ const int ct = rte->rte_waypt_ct();
poly_count = 0;
polybufx = new double[ct];
polybufy = new double[ct];
// to SHPT_ARC.
// We could potentially write SHPT_ARCZ, but we would have
// to address what to do when we don't have altitude data.
- assert(rte->rte_waypt_ct == poly_count);
+ assert(rte->rte_waypt_ct() == poly_count);
SHPObject* shpobject = SHPCreateSimpleObject(SHPT_ARC, poly_count,
polybufx, polybufy, polybufz);
int iShape = SHPWriteObject(ohandle, -1, shpobject);
skyforce_head_disp_cb(const route_head* head)
{
prev_wpt = nullptr;
- if (head->rte_waypt_ct <= 0) {
+ if (head->rte_waypt_ct() <= 0) {
return;
}
totalerror = 0;
/* short-circuit if we already have fewer than the max points */
- if (countopt && count >= rte->rte_waypt_ct) {
+ if (countopt && count >= rte->rte_waypt_ct()) {
return;
}
/* short-circuit if the route is impossible to simplify, too. */
- if (2 >= rte->rte_waypt_ct) {
+ if (2 >= rte->rte_waypt_ct()) {
return;
}
- xte_recs = new struct xte[rte->rte_waypt_ct];
+ xte_recs = new struct xte[rte->rte_waypt_ct()];
cur_rte = rte;
}
calculate(wpt, &dist, &speed, &course, nullptr, nullptr);
trkpt_dist = trkpt_dist + dist;
- if (track_points == trk_out->rte_waypt_ct) { /* I'm the last in that list */
+ if (track_points == trk_out->rte_waypt_ct()) { /* I'm the last in that list */
if (all_track_points != saved_track_points) { /* but not the overall latest */
flag = 1;
}
gbfwrite(bounding_box, 1, sizeof(bounding_box), tpo_file_out);
/* number of route points */
- gbfputint16(rte->rte_waypt_ct, tpo_file_out);
+ gbfputint16(rte->rte_waypt_ct(), tpo_file_out);
/* initialize the track length computation */
track_length = 0;
void TrackFilter::trackfilter_fill_track_list_cb(const route_head* track) /* callback for track_disp_all */
{
- if (track->rte_waypt_ct == 0) {
+ if (track->rte_waypt_ct() == 0) {
track_del_head(const_cast<route_head*>(track));
return;
}
void TrackFilter::trackfilter_minpoint_list_cb(const route_head* track)
{
- if (track->rte_waypt_ct < minimum_points) {
+ if (track->rte_waypt_ct() < minimum_points) {
track_del_head(const_cast<route_head*>(track));
return;
}
// Uggh. strftime format exposed to user.
gpsbabel::DateTime dt;
- if (track->rte_waypt_ct == 0) {
+ if (track->rte_waypt_ct() == 0) {
dt = default_time;
} else {
auto* wpt = track->waypoint_list.front();
}
}
- if (master->rte_waypt_ct == 0) {
+ if (master->rte_waypt_ct() == 0) {
track_del_head(master);
track_list.clear();
}
fatal(MYNAME "-split: Cannot split more than one track, please pack (or merge) before!\n");
} else if (!track_list.isEmpty()) {
route_head* master = track_list.first();
- int count = master->rte_waypt_ct;
+ int count = master->rte_waypt_ct();
int i, j;
double interval = -1; /* seconds */
}
}
- if (track->rte_waypt_ct == 0) {
+ if (track->rte_waypt_ct() == 0) {
track_del_head(track);
it = track_list.erase(it);
} else {
{
int segment_waypt_ct = point_ct - segment_ct_start;
if (debug) {
- fprintf(stderr, "%s %d ct: %d, waypt_count: %d\n", segment_type, header->rte_num, segment_waypt_ct, header->rte_waypt_ct);
+ fprintf(stderr, "%s %d ct: %d, waypt_count: %d\n", segment_type, header->rte_num, segment_waypt_ct, header->rte_waypt_ct());
}
- if (!debug && (segment_waypt_ct != header->rte_waypt_ct)) {
- fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct, segment_waypt_ct);
+ if (!debug && (segment_waypt_ct != header->rte_waypt_ct())) {
+ fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct(), segment_waypt_ct);
}
}
}
wpt_ = nullptr;
} else if (trk_) {
- if (trk_->rte_waypt_ct == 0) {
+ if (trk_->rte_waypt_ct() == 0) {
track_del_head(trk_);
}
trk_ = nullptr;